<template>
  <div>
    <BasicTable @register="registerTable">
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'way'">
          <Tag color="red">
            删除
          </Tag>      
        </template>

        <template v-if="column.key === 'status'">
          <Tag v-if="record.status==0" color="red">
            失败
          </Tag>
          <Tag v-if="record.status==1" color="blue">
            成功
          </Tag>
        </template>
        
        <template v-else-if="column.key === 'action'">
          <TableAction
            :actions="[
              {
                icon: 'clarity:note-edit-line',
                onClick: handleEdit.bind(null, record),
              },
              {
                icon: 'ant-design:delete-outlined',
                color: 'error',
                popConfirm: {
                  title: '是否确认删除',
                  placement: 'left',
                  confirm: handleDelete.bind(null, record),
                },
              },
            ]"
          />
        </template>
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts" setup>
  import { Tag } from 'ant-design-vue';
  import { BasicTable, useTable, TableAction } from '@/components/Table';
  import { getRoleListByPage } from '@/api/demo/system';

  import { columns, searchFormSchema } from './operation.data';

  defineOptions({ name: 'OperationLogManagement' });

  const [registerTable, { reload }] = useTable({
    title: '操作日志',
    api: getRoleListByPage,
    columns,
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    showIndexColumn: false,
    // actionColumn: {
    //   width: 80,
    //   title: '操作',
    //   dataIndex: 'action',
    //   // slots: { customRender: 'action' },
    //   fixed: undefined,
    // },
  });
</script>
